'''
试题编号：	201909-2
试题名称：	小明种苹果（续）
时间限制：	1.0s
内存限制：	512.0MB
问题描述：
'''
n = int(input())
num = []
for i in range(n):
    num.append(input().split())
T=0#剩余苹果总数
D=0#发生苹果掉落的苹果树颗数
E = 0#连续三棵树发生苹果掉落的组数
'''
4
4 74 -7 -12 -5
5 73 -8 -6 59 -4
5 76 -5 -10 60 -2
5 80 -6 -15 59 0
'''
e=[]
for i in range(n):
    z = int(num[i][1])
    for j in range(2,int(num[i][0])+1):
        if int(num[i][j]) > 0 :
            if z == int(num[i][j]):
                continue
            else:
                z = int(num[i][j])
                D+=1
                e.append(i)
                continue
        z = z + int(num[i][j])
    T=T+z
print(e)
for i in range(len(e)):
    try:
        if int(e[i]) +1 == int(e[i+1]) and int(e[i]) +2 == int(e[i+2]):
            E+=1
            print(str(i)+"******")

    except:
        try:
            if int(e[i]) + 1 == int(e[i+1]) and int(e[0]) == 0:
                E += 1
                print(str(i) + "+++++++++")

        except:
            if int(e[i]) == (n-1) and int(e[0]) == 0 and int(e[1]) == 1:
                E += 1
                print(str(i) + "--------")

print(T ,D ,E)
'''
5
4 10 0 9 0
4 10 -2 7 0
2 10 0
4 10 -3 5 0
4 10 -1 8 0
'''